Imports System.Configuration

Public Class frmInventoryMain
    Inherits System.Windows.Forms.Form
    Public LogFlag As Integer
    Public ImagePath As String = ConfigurationManager.AppSettings("ImagePath")
    Public MainTitle As String
    'Dim InvForm As New ICwholesaleInvoice
    'Dim GvsForm As New ICwholesaleQtn
    'Dim RtnForm As New ICwholesaleReturn
    'Dim PrqForm As New ICpurchaseOrder
    'Dim EvpForm As New ICShipment
    'Dim CvpForm As New ICcosting
    'Dim CrqForm As New ICPurchaseReturn
    'Dim ProdForm As New ICproducts
    'Dim EmlForm As New ICwholesaleLpo
    'Dim GrpForm As New ICgroups
    'Dim TrfForm As New ICtransfer
    'Dim AutoForm As New ICtransferAuto
    'Dim ProdRelationRpt As New ICProductGroupRelationRpt
    'Dim ProdHistoryRpt As New ICProductHistoryRpt
    'Dim ProdDist As New ICproductDistribution
    'Dim Qadj As New ICadjustQty
    'Dim Vadj As New ICadjustValue
    'Dim SampForm As New ICsamplesIssue
    'Dim KitsForm As New ICkits
    'Dim PcountForm As New ICcounting
    'Dim MatrixForm As New ARcusProdMatrix
    'Dim PriceForm As New ICpricing
    'Dim BinForm As New ICprodWHbin
    'Dim BarDupe As New ICbarDupe

    Dim InvForm As Object
    Dim GvsForm As Object
    Dim RtnForm As Object
    Dim PrqForm As Object
    Dim EvpForm As Object
    Dim CvpForm As Object
    Dim CrqForm As Object
    Dim ProdForm As Object
    Dim EmlForm As Object
    Dim GrpForm As Object
    Dim TrfForm As Object
    Dim AutoForm As Object
    Dim ProdRelationRpt As Object
    Dim ProdHistoryRpt As Object
    Dim ProdDist As Object
    Dim Qadj As Object
    Dim Vadj As Object
    Dim SampForm As Object
    Dim KitsForm As Object
    Dim PcountForm As Object
    Dim MatrixForm As Object
    Dim PriceForm As Object
    Dim BinForm As Object
    Dim BarDupe As Object
    Dim Classlist As Object
    Dim NewICTransferDSRRpt As Object
    Friend WithEvents MenuStrip1 As System.Windows.Forms.MenuStrip
    Friend WithEvents ChartOfAccountsToolStripMenuItem As System.Windows.Forms.ToolStripMenuItem
    Friend WithEvents ChartOfAccountsToolStripMenuItem1 As System.Windows.Forms.ToolStripMenuItem
    Friend WithEvents Panel1 As System.Windows.Forms.Panel
    Friend WithEvents CatToolStripMenuItem As System.Windows.Forms.ToolStripMenuItem
    Friend WithEvents ProductToolStripMenuItem1 As System.Windows.Forms.ToolStripMenuItem
    Friend WithEvents ProductCreationToolStripMenuItem As System.Windows.Forms.ToolStripMenuItem
    Friend WithEvents ProductMasterViewToolStripMenuItem As System.Windows.Forms.ToolStripMenuItem
    Friend WithEvents ProductMasterSearchToolStripMenuItem As System.Windows.Forms.ToolStripMenuItem
    Friend WithEvents UpdateCostQtyRSPToolStripMenuItem1 As System.Windows.Forms.ToolStripMenuItem
    'Friend WithEvents UserCompanyTableAdapter1 As SERPS.SERPSDataSet1TableAdapters.UserCompanyTableAdapter
    Dim DSRLeftout As Object

#Region " Windows Form Designer generated code "

    Public Sub New()
        MyBase.New()

        'This call is required by the Windows Form Designer.
        InitializeComponent()

        'Add any initialization after the InitializeComponent() call

    End Sub

    'Form overrides dispose to clean up the component list.
    Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
        If disposing Then
            If Not (components Is Nothing) Then
                components.Dispose()
            End If
        End If
        MyBase.Dispose(disposing)
    End Sub

    'Required by the Windows Form Designer
    Private components As System.ComponentModel.IContainer

    'NOTE: The following procedure is required by the Windows Form Designer
    'It can be modified using the Windows Form Designer.  
    'Do not modify it using the code editor.
    Friend WithEvents ttPosMenu As System.Windows.Forms.ToolTip
    Friend WithEvents Button2 As System.Windows.Forms.Button
    <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
        Me.components = New System.ComponentModel.Container()
        Dim resources As System.ComponentModel.ComponentResourceManager = New System.ComponentModel.ComponentResourceManager(GetType(frmInventoryMain))
        Me.ttPosMenu = New System.Windows.Forms.ToolTip(Me.components)
        Me.Button2 = New System.Windows.Forms.Button()
        Me.MenuStrip1 = New System.Windows.Forms.MenuStrip()
        Me.ChartOfAccountsToolStripMenuItem = New System.Windows.Forms.ToolStripMenuItem()
        Me.CatToolStripMenuItem = New System.Windows.Forms.ToolStripMenuItem()
        Me.ChartOfAccountsToolStripMenuItem1 = New System.Windows.Forms.ToolStripMenuItem()
        Me.ProductToolStripMenuItem1 = New System.Windows.Forms.ToolStripMenuItem()
        Me.ProductCreationToolStripMenuItem = New System.Windows.Forms.ToolStripMenuItem()
        Me.ProductMasterViewToolStripMenuItem = New System.Windows.Forms.ToolStripMenuItem()
        Me.UpdateCostQtyRSPToolStripMenuItem1 = New System.Windows.Forms.ToolStripMenuItem()
        Me.ProductMasterSearchToolStripMenuItem = New System.Windows.Forms.ToolStripMenuItem()
        Me.Panel1 = New System.Windows.Forms.Panel()
        Me.MenuStrip1.SuspendLayout()
        Me.SuspendLayout()
        '
        'Button2
        '
        Me.Button2.Font = New System.Drawing.Font("Microsoft Sans Serif", 8.25!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
        Me.Button2.Image = CType(resources.GetObject("Button2.Image"), System.Drawing.Image)
        Me.Button2.Location = New System.Drawing.Point(363, -12)
        Me.Button2.Name = "Button2"
        Me.Button2.Size = New System.Drawing.Size(28, 24)
        Me.Button2.TabIndex = 75
        Me.ttPosMenu.SetToolTip(Me.Button2, "Product Auto Transfer")
        '
        'MenuStrip1
        '
        Me.MenuStrip1.Font = New System.Drawing.Font("Calibri", 11.25!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
        Me.MenuStrip1.Items.AddRange(New System.Windows.Forms.ToolStripItem() {Me.ChartOfAccountsToolStripMenuItem, Me.ProductToolStripMenuItem1})
        Me.MenuStrip1.Location = New System.Drawing.Point(0, 0)
        Me.MenuStrip1.Name = "MenuStrip1"
        Me.MenuStrip1.Size = New System.Drawing.Size(928, 26)
        Me.MenuStrip1.TabIndex = 100
        Me.MenuStrip1.Text = "MenuStrip1"
        '
        'ChartOfAccountsToolStripMenuItem
        '
        Me.ChartOfAccountsToolStripMenuItem.DropDownItems.AddRange(New System.Windows.Forms.ToolStripItem() {Me.CatToolStripMenuItem, Me.ChartOfAccountsToolStripMenuItem1})
        Me.ChartOfAccountsToolStripMenuItem.Name = "ChartOfAccountsToolStripMenuItem"
        Me.ChartOfAccountsToolStripMenuItem.Size = New System.Drawing.Size(126, 22)
        Me.ChartOfAccountsToolStripMenuItem.Text = "Product Category"
        '
        'CatToolStripMenuItem
        '
        Me.CatToolStripMenuItem.Name = "CatToolStripMenuItem"
        Me.CatToolStripMenuItem.Size = New System.Drawing.Size(225, 22)
        Me.CatToolStripMenuItem.Text = "Product Category"
        '
        'ChartOfAccountsToolStripMenuItem1
        '
        Me.ChartOfAccountsToolStripMenuItem1.Name = "ChartOfAccountsToolStripMenuItem1"
        Me.ChartOfAccountsToolStripMenuItem1.Size = New System.Drawing.Size(225, 22)
        Me.ChartOfAccountsToolStripMenuItem1.Text = "Product Category - View"
        '
        'ProductToolStripMenuItem1
        '
        Me.ProductToolStripMenuItem1.DropDownItems.AddRange(New System.Windows.Forms.ToolStripItem() {Me.ProductCreationToolStripMenuItem, Me.ProductMasterViewToolStripMenuItem, Me.UpdateCostQtyRSPToolStripMenuItem1, Me.ProductMasterSearchToolStripMenuItem})
        Me.ProductToolStripMenuItem1.Name = "ProductToolStripMenuItem1"
        Me.ProductToolStripMenuItem1.Size = New System.Drawing.Size(68, 22)
        Me.ProductToolStripMenuItem1.Text = "Product"
        '
        'ProductCreationToolStripMenuItem
        '
        Me.ProductCreationToolStripMenuItem.Name = "ProductCreationToolStripMenuItem"
        Me.ProductCreationToolStripMenuItem.Size = New System.Drawing.Size(258, 22)
        Me.ProductCreationToolStripMenuItem.Text = "Product Master - Create"
        '
        'ProductMasterViewToolStripMenuItem
        '
        Me.ProductMasterViewToolStripMenuItem.Name = "ProductMasterViewToolStripMenuItem"
        Me.ProductMasterViewToolStripMenuItem.Size = New System.Drawing.Size(258, 22)
        Me.ProductMasterViewToolStripMenuItem.Text = "Product Master Deatils - View"
        '
        'UpdateCostQtyRSPToolStripMenuItem1
        '
        Me.UpdateCostQtyRSPToolStripMenuItem1.Name = "UpdateCostQtyRSPToolStripMenuItem1"
        Me.UpdateCostQtyRSPToolStripMenuItem1.Size = New System.Drawing.Size(258, 22)
        Me.UpdateCostQtyRSPToolStripMenuItem1.Text = "Update Avg.Cost/Qty/RSP"
        '
        'ProductMasterSearchToolStripMenuItem
        '
        Me.ProductMasterSearchToolStripMenuItem.Name = "ProductMasterSearchToolStripMenuItem"
        Me.ProductMasterSearchToolStripMenuItem.Size = New System.Drawing.Size(258, 22)
        Me.ProductMasterSearchToolStripMenuItem.Text = "Product Master Search"
        '
        'Panel1
        '
        Me.Panel1.BackColor = System.Drawing.Color.SlateGray
        Me.Panel1.Dock = System.Windows.Forms.DockStyle.Fill
        Me.Panel1.Location = New System.Drawing.Point(0, 26)
        Me.Panel1.Name = "Panel1"
        Me.Panel1.Size = New System.Drawing.Size(928, 597)
        Me.Panel1.TabIndex = 102
        '
        'frmInventoryMain
        '
        Me.AutoScaleBaseSize = New System.Drawing.Size(7, 19)
        Me.BackColor = System.Drawing.SystemColors.ActiveCaption
        Me.ClientSize = New System.Drawing.Size(928, 623)
        Me.Controls.Add(Me.Panel1)
        Me.Controls.Add(Me.MenuStrip1)
        Me.Controls.Add(Me.Button2)
        Me.Font = New System.Drawing.Font("Calibri", 11.25!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
        Me.FormBorderStyle = System.Windows.Forms.FormBorderStyle.Fixed3D
        Me.IsMdiContainer = True
        Me.MainMenuStrip = Me.MenuStrip1
        Me.MaximizeBox = False
        Me.Name = "frmInventoryMain"
        Me.ShowInTaskbar = False
        Me.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen
        Me.Text = "Inventory Manager"
        Me.WindowState = System.Windows.Forms.FormWindowState.Maximized
        Me.MenuStrip1.ResumeLayout(False)
        Me.MenuStrip1.PerformLayout()
        Me.ResumeLayout(False)
        Me.PerformLayout()

    End Sub

#End Region
    Private Sub PosMain_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        ValidUser = True
        LogFlag = 1

    End Sub
   
    Private Sub PosMain_Closing(ByVal sender As Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles MyBase.Closing
        If Not PanelEmpty() Then
            MsgBox("Data exist in the form." & vbLf & "Settle/Void/Save", MsgBoxStyle.Information, "Inventory Manager")
            e.Cancel = True
        End If
    End Sub

    Private Function PanelEmpty() As Boolean
        If Panel1.Controls.Count > 0 Then
            Dim ActiveCtrl As String
            ActiveCtrl = Panel1.Controls.Item(0).Name
            Select Case ActiveCtrl
                Case "ICretailInvoice"
                    Dim cm As CurrencyManager = BindingContext(InvForm.DataGrid1.DataSource, InvForm.DataGrid1.DataMember)
                    Dim dv As DataView = cm.List
                    Dim mrow As Integer
                    mrow = dv.Table.Rows.Count
                    If mrow > 0 Then
                        PanelEmpty = False
                    Else
                        PanelEmpty = True
                    End If
                Case "ICretailReturn"
                    Dim cm As CurrencyManager = BindingContext(RtnForm.DataGrid1.DataSource, RtnForm.DataGrid1.DataMember)
                    Dim dv As DataView = cm.List
                    Dim mrow As Integer
                    mrow = dv.Table.Rows.Count
                    If mrow > 0 Then
                        PanelEmpty = False
                    Else
                        PanelEmpty = True
                    End If
                Case Else
                    PanelEmpty = True
            End Select
        Else
            PanelEmpty = True
        End If
    End Function

    Private Sub ChartOfAccountsToolStripMenuItem1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ChartOfAccountsToolStripMenuItem1.Click
        Dim ApData As New APdataLogic
        If ApData.IsValidUserOption(UserID, CompanyID, 57) = True Then
            If Not PanelEmpty() Then
                MsgBox("Data exist in the form." & vbLf & "Settle/Void/Suspend.", MsgBoxStyle.Information, "Inventory Manager")
                Exit Sub
            End If
            Panel1.Controls.Clear()
            If GrpForm Is Nothing Then
                GrpForm = New frmProductCategoryView
                GrpForm.MdiParent = Me
            End If
            Panel1.Controls.Add(GrpForm)
            GrpForm.Show()
        Else
            MsgBox("Access Denied !", MsgBoxStyle.Critical, "Inventory Manager")
        End If
        ApData = Nothing
    End Sub

    Dim icpAdd As frmProductMasterAdd
    Dim icgAdd As frmProductCategoryAdd

    Private Sub CatToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CatToolStripMenuItem.Click
        Dim ApData As New APdataLogic
        If ApData.IsValidUserOption(UserID, 1, 55) = True Then
            icgAdd = New frmProductCategoryAdd
            icgAdd.Show()
        Else
            MsgBox("Access Denied !", MsgBoxStyle.Critical, "Inventory Manager")
        End If
    End Sub
    Dim argAdd As frmAPSupplierGroupAdd

    Private Sub SupplierGroupToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
        argAdd = New frmAPSupplierGroupAdd
        argAdd.Show()
    End Sub

    Dim arcAdd As frmAPSupplierAdd
    Dim updateCQR As frmUpdateCostQtyRSP

    Private Sub ProductCreationToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ProductCreationToolStripMenuItem.Click
        Dim ApData As New APdataLogic
        If ApData.IsValidUserOption(UserID, 1, 58) = True Then
            icpAdd = New frmProductMasterAdd
            icpAdd.ShowDialog()
        Else
            MsgBox("Access Denied !", MsgBoxStyle.Critical, "Inventory Manager")
        End If
        ApData = Nothing
    End Sub

    Private Sub ProductMasterViewToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ProductMasterViewToolStripMenuItem.Click
        Dim ApData As New APdataLogic
        If ApData.IsValidUserOption(UserID, CompanyID, 60) = True Then
            If Not PanelEmpty() Then
                MsgBox("Data exist in the form." & vbLf & "Settle/Void/Suspend.", MsgBoxStyle.Information, "Inventory Manager")
                Exit Sub
            End If
            Panel1.Controls.Clear()
            If ProdForm Is Nothing Then
                ProdForm = New frmProductMasterView
                ProdForm.MdiParent = Me
            End If
            Panel1.Controls.Add(ProdForm)
            ProdForm.Show()

        Else
            MsgBox("Access Denied !", MsgBoxStyle.Critical, "Inventory Manager")
        End If
        ApData = Nothing
    End Sub

    Private Sub UpdateCostQtyRSPToolStripMenuItem1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles UpdateCostQtyRSPToolStripMenuItem1.Click
        Dim ApData As New APdataLogic
        If ApData.IsValidUserOption(UserID, CompanyID, 71) = True Then
            updateCQR = New frmUpdateCostQtyRSP
            updateCQR.ShowDialog()
        Else
            MsgBox("Access Denied !", MsgBoxStyle.Critical, "Inventory Manager")
        End If
    End Sub
    Dim serch As frmProductSearch

    Private Sub ProductMasterSearchToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ProductMasterSearchToolStripMenuItem.Click
        Dim ApData As New APdataLogic
        If ApData.IsValidUserOption(UserID, CompanyID, 59) = True Then
            serch = New frmProductSearch
            serch.ShowDialog()
        Else
            MsgBox("Access Denied !", MsgBoxStyle.Critical, "Inventory Manager")
        End If

    End Sub
End Class
